﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zhao.Common.Helper;
using Zhao.Models.AppletDto;
using Zhao.Models.DTO;
using Zhao.Models.Entity;

namespace Zhao.IServer.Field
{
    /// <summary>
    /// 预约表（核心业务表）
    ///</summary>
    public interface IAppointmentsServer : IBaseService<Appointments>
    {
        /// <summary>
        /// 预约场地
        /// </summary>
        /// <returns></returns>
        public Task<ApiResult> BookingAVenue(Guid guid, ReservationDto reservation);
        /// <summary>
        /// 根据id 获取预约详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Task<ApiResult<AppointmentsDto>> GetAppointmentById(int id);
        /// <summary>
        /// 修改订单状态
        /// </summary>
        /// <param name="id"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public Task<ApiResult> UpdateAppointmentStatus(int id, short status);
        /// <summary>
        /// 预约订单取消
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Task<ApiResult> CancelAppointment(int id);
        /// <summary>
        /// 根据条件表达式返回相关数据
        /// </summary>
        /// <param name="expressionable"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public Task<PageModel<AppointmentsDto>> GetInfos(Expressionable<Appointments, Fields> expressionable, int pageIndex, int pageSize);

        #region 小程序端API

        /// <summary>
        /// 预约场地
        /// </summary>
        /// <returns></returns>
        public Task<ApiResult> AppleBookingAVenue(AppleReservation reservation);

        /// <summary>
        /// 获取用户的预约订单信息
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="status">订单状态：-1-全部，0-待支付，3-已预约，5-已完成，7-已取消</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页大小</param>
        /// <returns></returns>
        public Task<PageModel<AppointmentOrderDto>> GetUserAppointmentOrders(int userId, short? status = -1, int pageIndex = 1, int pageSize = 10);

        /// <summary>
        /// 取消用户的预约
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <param name="appointmentIds">要取消的预约ID列表</param>
        /// <returns>操作结果</returns>
        public Task<ApiResult> CancelUserAppointments(int userId, int orderId);


        #endregion

        /// <summary>
        /// 更新历史场地预约状态
        /// </summary>
        /// <returns></returns>
        public Task<int> UpdateHistoricalAppointmentsStatusAsync();
    }
}
